import type { detailsCouponType } from '@/types/eat'
import type { userInfoType } from '@/types/my'
import { http } from '@/utils/http'

/**
 *
 * * getAllFavoriteDevicesApi 获取所有收藏设备
 * @returns
 */
export const getAllFavoriteDevicesApi = (data: {
  clientId: string
  latitude: string
  longitude: string
}) => {
  return http<any>({
    method: 'GET',
    url: '/client/favorites',
    data,
  })
}

/**
 * * 修改用户个人信息 接口
 * @param id: number
 * @param nickName: string
 * @param mobile: string
 * @param sex?: number
 * @param headImg?: string
 * @param email?: string
 * @param birthday?: string
 */
export const putSetUserInfoApi = (data: userInfoType) => {
  return http<any>({
    method: 'PUT',
    url: '/client/edit',
    data,
  })
}

/**
 *
 * * 获取设备点位的社群二维码 接口
 * @param machineId 设备id
 */
export const getCommunityQrCodeApi = (data: { machineId?: string }) => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'GET',
    url: '/client/machine/findMarAssociationQrCode',
    data: { ...data, cityName },
  })
}
/**
 * * 订单详情优惠券 接口 /client/coupon/order/detail/list
 * @param machineId 设备id
 */
export const postDetailsCouponApi = (data: detailsCouponType) => {
  return http<any>({
    method: 'POST',
    url: '/client/coupon/order/detail/list',
    data,
  })
}
/**
 * * 邀请有礼-统计邀请人数和奖励 接口  /clientActivity/countClientActivity
 * @param marketingId 营销id
 */
export const getCountClientActivityApi = (data: { marketingId: number }) => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'GET',
    url: '/client/clientActivity/countClientActivity',
    data: { ...data, cityName },
  })
}

/**
 * * 邀请有礼-被邀请人列表 接口  /clientActivity/getActivityClient
 * @param marketingId 营销id
 */
export const getActivityClientApi = (data: { marketingId: string }) => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'GET',
    url: '/client/clientActivity/getActivityClient',
    data: { ...data, cityName },
  })
}
/**
 * * 获取活动配置信息 接口  /clientActivity/getByMarketingId
 * @param marketingId 营销id
 */
export const getByMarketingApi = (data: { marketingId: string | null }) => {
  return http<any>({
    method: 'GET',
    url: '/client/clientActivity/getByMarketingId',
    data,
  })
}

/**
 * * 获取邀请有礼配置信息 接口  /client/clientActivity/getInvitation
 * @param marketingId 营销id
 */
export const getInvitationApi = () => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'GET',
    url: '/client/clientActivity/getInvitation',
    data: { cityName },
  })
}

/**
 * * 活动-领取券 接口  /client/coupon/activiryAcquire
 * @param marketingId 营销id
 * @param invitationClientId 邀请人id
 */
export const postActiviryAcquireApi = (data: {
  marketingId?: number | null
  invitationClientId?: string | null
}) => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'POST',
    url: '/client/coupon/activiryAcquire',
    data: { ...data, cityName },
  })
}
/**获取被邀请人页面背景图 */
export const postActivityInfoApi = (data: {
  marketingId?: number | null
  invitationClientId?: string | null
}) => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'POST',
    url: '/client/coupon/activity/info',
    data: { ...data, cityName },
  })
}
/**
 * * 核销券 接口  /client/coupon/verification/${marCouponExportId}
 * @param marCouponExportId 核销id
 */
export const postMarCouponExportIdApi = (marCouponExportId?: string) => {
  return http<any>({
    method: 'POST',
    url: `/client/coupon/verification/${marCouponExportId}`,
  })
}
/**
 * * 获取积分 接口  /clientIntegral/list
 */
export const getQiaFanLiApi = (data: { pageNum: number; pageSize: number }) => {
  return http<any>({
    method: 'GET',
    url: `/client/clientIntegral/list`,
    data,
  })
}

/**
 * * 获取用户详情 接口  /client/info
 */
export const getUserDetailsApi = () => {
  return http<any>({
    method: 'GET',
    url: `/client/info`,
  })
}
/**
 * * 获取礼包 接口  /client/coupon/findCouponPack
 * @param couponPackId 礼包id  string
 */
export const getFindCouponPackApi = (data: { couponPackId?: string | null }) => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'GET',
    url: `/client/coupon/findCouponPack`,
    data: { ...data, cityName },
  })
}

/**
 * * 领取礼包 接口   `/client/coupon/couponPack/${couponPackId}`
 * @param couponPackId 礼包id  string
 */
export const postCouponPackApi = (couponPackId?: string | null) => {
  const cityName = JSON.parse(uni.getStorageSync('location'))?.location?.cityName || '杭州市'
  return http<any>({
    method: 'POST',
    url: `/client/coupon/couponPack/${couponPackId}`,
    data: { cityName },
  })
}
/**
 *  获取活动详细信息 /client/activity-sign-ins/activityDetails
 */
export const getActivityDetailsApi = (data: {
  activitySignInsId: string | null
  cityName?: string | null
}) => {
  return http<any>({
    method: 'GET',
    url: `/client/activity-sign-ins/activityDetails`,
    data,
  })
}
/**
 * 参加活动-立即参与   `/client/activity-sign-ins/join`
 * @param activitySignInsId   string
 */
export const getJoinApi = (data: { activitySignInsId: string | null }) => {
  return http<any>({
    method: 'GET',
    url: `/client/activity-sign-ins/join`,
    data,
  })
}
/**
 * 领取奖励-立即领取  `/client/activity-sign-ins/receive`
 * @param activitySignInsId   string
 */
export const getReceiveApi = (data: { activitySignInsId: string | null }) => {
  return http<any>({
    method: 'GET',
    url: `/client/activity-sign-ins/receive`,
    data,
  })
}
/**
 * * 兑换记录   `/client/activity-sign-ins/record`
 * @param activitySignInsId   string
 */
export const getExchangeRecordApi = (data: { activitySignInsId: string | null }) => {
  return http<any>({
    method: 'GET',
    url: `/client/activity-sign-ins/record`,
    data,
  })
}
